package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.mapper.DtsIssueMapper;
import com.qf.pojo.DtsIssue;
import com.qf.service.DtsIssueService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * @author 邢式瑞
 * @version 1.0
 * @project E-commercebackGroundManagementSystem
 * @date 2022/9/24 13:24
 */
@Service
public class DtsIssueServiceImpl implements DtsIssueService {
    @Autowired
    private DtsIssueMapper dtsIssueMapper;
    @Override
    public Page<DtsIssue> selectpage(Integer page, Integer limit, String sort, String order, String question) {
        Page<DtsIssue> dtsIssuePage = new Page<>(page, limit);
        QueryWrapper<DtsIssue> dtsIssueQueryWrapper = new QueryWrapper<>();
    dtsIssueQueryWrapper.orderBy(!StringUtils.isEmpty(sort),"asc".equalsIgnoreCase(order),sort).like(!StringUtils.isEmpty(question),"question",question).eq("deleted",false);
        return dtsIssueMapper.selectPage(dtsIssuePage,dtsIssueQueryWrapper);
    }

    @Override
    public void insert(DtsIssue dtsIssue) {
        dtsIssueMapper.insert(dtsIssue);
    }

    @Override
    public void update(DtsIssue dtsIssue) {
      dtsIssueMapper.updateById(dtsIssue);
    }

    @Override
    public void delete(DtsIssue dtsIssue) {
 dtsIssueMapper.updateById(dtsIssue);
    }
}
